import request from '@/utils/request'

// 查询保养计划列表
export function listMaintenancePlan(query) {
  return request({
    url: '/ldzl-sb/sb/maintenance/plan/list',
    method: 'get',
    params: query
  })
}

// 查询保养计划详细
export function getMaintenancePlan(planId) {
  return request({
    url: '/ldzl-sb/sb/maintenance/plan/' + planId,
    method: 'get'
  })
}

// 新增保养计划
export function addMaintenancePlan(data) {
  return request({
    url: '/ldzl-sb/sb/maintenance/plan',
    method: 'post',
    data: data
  })
}

// 修改保养计划
export function updateMaintenancePlan(data) {
  return request({
    url: '/ldzl-sb/sb/maintenance/plan',
    method: 'put',
    data: data
  })
}

// 删除保养计划
export function deleteMaintenancePlan(planId) {
  return request({
    url: '/ldzl-sb/sb/maintenance/plan/' + planId,
    method: 'delete'
  })
}

// 更新保养计划状态
export function updateMaintenancePlanStatus(planId, status) {
  return request({
    url: '/ldzl-sb/sb/maintenance/plan/status/' + planId + '/' + status,
    method: 'put'
  })
}

// 生成保养记录
export function generateMaintenanceRecord(planId) {
  return request({
    url: '/ldzl-sb/sb/maintenance/plan/generate/' + planId,
    method: 'post'
  })
}

// 获取保养计划可用设备
export function getAvailableEquipments(typeId) {
  return request({
    url: '/ldzl-sb/sb/equipment/list/byType',
    method: 'get',
    params: { typeId: typeId }
  })
}

// 获取所有可用设备列表（不按类型过滤）
export function getAllEquipments() {
  return request({
    url: '/ldzl-sb/sb/equipment/list/all',
    method: 'get'
  })
}

// 获取保养配置列表
export function getMaintenanceConfigList() {
  return request({
    url: '/ldzl-sb/sb/maintenance/config/list',
    method: 'get'
  })
}

// 获取设备列表
export function getEquipmentList(query) {
  return request({
    url: '/ldzl-sb/sb/equipment/list',
    method: 'get',
    params: query
  })
} 

// 检查计划编号唯一性
export function checkPlanCodeUnique(planCode) {
  return request({
    url: '/ldzl-sb/sb/maintenance/plan/check/' + planCode,
    method: 'get'
  })
}

// 生成计划编号
export function generatePlanCode() {
  return request({
    url: '/ldzl-sb/sb/maintenance/plan/generateCode',
    method: 'get'
  })
} 